﻿@{
    // Model is Model.Menu from the layout (Layout.Menu)
    Model.Classes.Add("nav navbar-nav");
    
    var tag = Tag(Model, "ul");

    var items = (IList<dynamic>)Enumerable.Cast<dynamic>(Model.Items);
    
    if (items.Any()) {
        items[0].Classes.Add("first");
        items[items.Count - 1].Classes.Add("last");
    }    
}
<nav role="navigation">
    @tag.StartElement
    @* see MenuItem shape template *@
    
    @foreach (var item in Model.Items)
    {
        @Display(item)
    }
    
    @tag.EndElement
</nav>
